Fix compatible issue with transformers 5.0+#2328
Merged
xiaoyu-work merged 8 commits intomainfrom Feb 23, 2026
Merged
Conversation
justinchuby
reviewed
Feb 10, 2026
titaiwangms
reviewed
Feb 10, 2026
xadupre
reviewed
Feb 10, 2026
xadupre
reviewed
Feb 10, 2026
justinchuby
approved these changes
Feb 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes
This pull request introduces compatibility updates for Hugging Face Transformers 5.0 and improves handling of dynamic cache and input formats in Olive's ONNX conversion and training utilities. It also updates tests and requirements to reflect these changes and ensure robust model export and training workflows.
Transformers 5.0 Compatibility
DynamicLayer.lazy_initialization,past_key_values, and dynamic shapes to support the new DynamicCache format in Transformers >= 5.0. This ensures models using dynamic cache export correctly withtorch.export._export_pytorch_modellogic to apply the new patches and conversions only for Transformers >= 5.0, while maintaining legacy support for older versions.Training Argument Handling
create_training_argsto remove fields not valid for Transformers 5.0 and excludeNonevalues, allowing Transformers to use its own defaults.Test Suite Updates
trust_remote_codeparameter and update expected file counts and tokenizer types for Transformers 5.0. [1] [2] [3] [4]floatbefore comparison, ensuring consistency across dtypes.Requirements Adjustments
onnxscriptversion to<0.6.1and removed the Transformers version pin, reflecting confidence in test suite compatibility with Transformers 5.0. [1] [2]Checklist before requesting a review
lintrunner -a(Optional) Issue link